<template>
  <el-header>
    <div class="system-title">电商后台管理系统</div>
    <div>
      <span class="welcome"> 您好，{{ getUsername }} </span>
      <el-button type="primary" @click="logout" plain>退出</el-button>
    </div>
  </el-header>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "",
  data() {
    return {};
  },
  watch: {},
  props: {},
  components: {},
  computed: {
    ...mapGetters(["getUsername"])
  },
  mounted() {},
  methods: {
    toggleCollapse() {},
    logout() {
      this.$confirm("是否要退出?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "退出成功!"
          });
          //   清除token切换到登录页面
          window.localStorage.removeItem("tokenLogin");
          this.$router.push("/login");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    }
  },
  filters: {}
};
</script>

<style scoped lang="scss">
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #545c64;
  width: 100%;
}

.welcome {
  color: white;
}
.system-title {
  flex: 1;
  font-size: 28px;
  color: white;
}
</style>
